package com.monkey.algorithm.chapter2

import com.monkey.helper.ResourcesHelper
import org.junit.Assert
import org.junit.Test
import java.io.File

/**
 * 作者：Monkey
 * 日期：2018/2/10
 */
class InsertionSortTest {

    @Test
    fun sort() {
        val str = ResourcesHelper.readLine("algs4-data${File.separator}tiny.txt")
        val list = str.split(" ").map { it as Comparable<String> }.toTypedArray()
        println("before sort")
        InsertionSort.show(list)
        InsertionSort.sort(list)
        println("after sort")
        InsertionSort.show(list)
        Assert.assertTrue(InsertionSort.isSorted(list))
    }
}